//
//  UIBarButtonItem+Extension.swift
//  swift3.0项目开始
//
//  Created by 龚昕炜 on 16/7/28.
//  Copyright © 2016年 龚昕炜. All rights reserved.
//

import UIKit

extension UIBarButtonItem {
    
    convenience init(title: String, fontSize: CGFloat = 16, target: AnyObject?, action: Selector, isBack: Bool = false) {
        
        let btn: UIButton = UIButton()
        
        btn.setTitle(title, for: .normal)
        
        btn.setTitleColor(UIColor.darkGray(), for: .normal)
        
        btn.setTitleColor(UIColor.orange(), for: .highlighted)
                
     
        btn.addTarget(target, action: action, for: .touchUpInside)
        
        if isBack {
            
            let imageName = "NavBack"
            
            btn.setImage(UIImage.init(named: imageName), for: .normal)
            btn.setImage(UIImage.init(named: imageName), for: .highlighted)
            
        }
        
        btn.sizeToFit()
        
        self.init(customView: btn)
    }
    
}
